//
//  NewsDetailViewController.m
//  Toyohu
//
//  Created by Heige on 16/4/21.
//  Copyright © 2016年 celia. All rights reserved.
//

#import "NewsDetailViewController.h"
#import <WebKit/WebKit.h>
#define WIDTH self.view.bounds.size.width
#define HEIGHT self.view.bounds.size.height
@interface NewsDetailViewController ()<WKNavigationDelegate>
@property (nonatomic,strong) WKWebView *wkWebView;
@end

@implementation NewsDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.hidden = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    //导航栏左边项
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftButton.frame = CGRectMake(0, 0, 10, 15);
    [leftButton setBackgroundImage:[UIImage imageNamed:@"ARROW---LEFT@2x"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(goBackPreviousPage) forControlEvents:UIControlEventTouchDown];
    
    UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftButtonItem;
    
    UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 30)];
    navLabel.textColor = [UIColor whiteColor];
    navLabel.backgroundColor = [UIColor clearColor];
    navLabel.textAlignment = NSTextAlignmentCenter;
    navLabel.text = @"新闻详情";
    navLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:22];
    self.navigationItem.titleView = navLabel;
    
    
    _wkWebView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 64, WIDTH, HEIGHT-64)];
    _wkWebView.navigationDelegate = self;

    [self.view addSubview:_wkWebView];
    
    if (_url) {
        NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:_url]];
        [_wkWebView loadRequest:request];
        
    }
}



-(void)goBackPreviousPage{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
